<template>
  <Layout :class="'bg-white p-2'">
    <Layout :class="'bg-white'">
      <Form :label-width="100">
        <h2>学生线索详细</h2>

        <FormItem class="w-50" label="线索来源">
          <Input v-model="resource.source" placeholder="请输入回访人"></Input>
        </FormItem>

        <FormItem class="w-50" label="线索状态">
          <Input v-model="resource.statu" placeholder="身份证号"></Input>
        </FormItem>

        <FormItem class="w-50" label="应聘职位">
          <Input v-model="resource.ypzw" placeholder="身份证正面"></Input>
        </FormItem>

        <FormItem class="w-50" label="从事工作">
          <Input v-model="resource.csgz" placeholder="身份证背面"></Input>
        </FormItem>

        <FormItem class="w-50" label="投递公司名称">
          <Input v-model="resource.tdgsmc" placeholder="身份证手持"></Input>
        </FormItem>

        <FormItem class="w-50" label="备注">
          <Input v-model="resource.bz" placeholder="出生日期"></Input>
        </FormItem>

        <FormItem class="w-50" label="跟进人">
          <Input v-model="resource.autor" placeholder="出生日期"></Input>
        </FormItem>

        <FormItem class="w-50" label="阶段Id">
          <Input v-model="resource.stageId" placeholder="出生日期"></Input>
        </FormItem>

        <!-- 	<FormItem class="text-right">
					<Button @click="submit" type="primary">提交</Button>
					<Button @click="cancel" class="ml-2">取消</Button>
				</FormItem> -->
      </Form>

      <h3>学生线索阶段回访</h3>
      <Table
        border
        :class="'m-1'"
        :columns="resourceBackviewTableInfo.columnInfo"
        :data="resourceBackviewTableInfo.data"
      >
        <template slot-scope="{ row, index }" slot="status">
          <span v-if="row.statu">开</span>
          <span v-else>关</span>
        </template>
        <template slot-scope="{ row, index }" slot="action">
          <!-- <Row>
						<Col>
						<Menu >
							<Submenu name="1">
								<template slot="title">
									<Icon type="ios-paper" />
									操作选项
								</template>
								<Button type="error" size="small" @click="remove(row.backviewId)">删除</Button>
								<br>
								<Button type="primary" size="small" style="margin-right: 5px"
									@click="showPersonDetail(row)">详细</Button>
								<br>
								<Button type="error" @click="showLifeCycle(row)">生命周期</Button>
							</Submenu>
						</Menu>
						</Col>
					</Row> -->
        </template>
      </Table>
      <br />

      <Form :label-width="100">
        <h2>学生接待详细</h2>

        <FormItem class="w-50" label="接待描述">
          <Input v-model="interview.des" placeholder="接待描述"></Input>
        </FormItem>

        <FormItem class="w-50" label="接待标志">
          <Input v-model="interview.flg" placeholder="接待标志"></Input>
        </FormItem>

        <FormItem class="w-50" label="接待日期">
          <Input v-model="interview.dateTime" placeholder="接待日期"></Input>
        </FormItem>

        <FormItem class="w-50" label="接待人">
          <Input v-model="interview.autor" placeholder="接待人"></Input>
        </FormItem>

        <FormItem class="w-50" label="应聘职位">
          <Input v-model="interview.ypzw" placeholder="应聘职位"></Input>
        </FormItem>

        <FormItem class="w-50" label="阶段Id">
          <Input v-model="interview.stageId" placeholder="阶段Id"></Input>
        </FormItem>

        <!-- 	<FormItem class="text-right">
					<Button @click="submit" type="primary">提交</Button>
					<Button @click="cancel" class="ml-2">取消</Button>
				</FormItem> -->
      </Form>

      <h3>学生接待阶段回访</h3>
      <Table
        border
        :class="'m-1'"
        :columns="interviewBackviewTableInfo.columnInfo"
        :data="interviewBackviewTableInfo.data"
      >
        <template slot-scope="{ row, index }" slot="status">
          <span v-if="row.statu">开</span>
          <span v-else>关</span>
        </template>
        <template slot-scope="{ row, index }" slot="action">
          <!-- <Row>
						<Col>
						<Menu >
							<Submenu name="1">
								<template slot="title">
									<Icon type="ios-paper" />
									操作选项
								</template>
								<Button type="error" size="small" @click="remove(row.backviewId)">删除</Button>
								<br>
								<Button type="primary" size="small" style="margin-right: 5px"
									@click="showPersonDetail(row)">详细</Button>
								<br>
								<Button type="error" @click="showLifeCycle(row)">生命周期</Button>
							</Submenu>
						</Menu>
						</Col>
					</Row> -->
        </template>
      </Table>
      <br />

      <Form :label-width="100">
        <h2>学生试听详细</h2>

        <FormItem class="w-50" label="试听描述">
          <Input v-model="tryListening.des" placeholder="接待描述"></Input>
        </FormItem>

        <FormItem class="w-50" label="试听状态">
          <Input v-model="tryListening.statu" placeholder="接待标志"></Input>
        </FormItem>

        <FormItem class="w-50" label="推进人">
          <Input v-model="tryListening.autor" placeholder="接待日期"></Input>
        </FormItem>

        <FormItem class="w-50" label="试听日期">
          <Input v-model="tryListening.dateTime" placeholder="接待人"></Input>
        </FormItem>

        <FormItem class="w-50" label="阶段Id">
          <Input v-model="tryListening.stageId" placeholder="应聘职位"></Input>
        </FormItem>

        <!-- 	<FormItem class="text-right">
					<Button @click="submit" type="primary">提交</Button>
					<Button @click="cancel" class="ml-2">取消</Button>
				</FormItem> -->
      </Form>

      <h3>学生试听阶段回访</h3>
      <Table
        border
        :class="'m-1'"
        :columns="tryBackviewTableInfo.columnInfo"
        :data="tryBackviewTableInfo.data"
      >
        <template slot-scope="{ row, index }" slot="status">
          <span v-if="row.statu">开</span>
          <span v-else>关</span>
        </template>
        <template slot-scope="{ row, index }" slot="action">
          <!-- <Row>
						<Col>
						<Menu >
							<Submenu name="1">
								<template slot="title">
									<Icon type="ios-paper" />
									操作选项
								</template>
								<Button type="error" size="small" @click="remove(row.backviewId)">删除</Button>
								<br>
								<Button type="primary" size="small" style="margin-right: 5px"
									@click="showPersonDetail(row)">详细</Button>
								<br>
								<Button type="error" @click="showLifeCycle(row)">生命周期</Button>
							</Submenu>
						</Menu>
						</Col>
					</Row> -->
        </template>
      </Table>

      <!--
			<Table border :class="'m-1'" :columns="tableInfo.columnInfo" :data="tableInfo.data">
				<template slot-scope="{ row, index }" slot="status">
					<span v-if="row.statu">开</span>
					<span v-else>关</span>
				</template>
				<template slot-scope="{ row, index }" slot="action">
					<Row>
						<Col>
						<Menu >
							<Submenu name="1">
								<template slot="title">
									<Icon type="ios-paper" />
									操作选项
								</template>
								<Button type="error" size="small" @click="remove(row.backviewId)">删除</Button>
								<br>
								<Button type="primary" size="small" style="margin-right: 5px"
									@click="show(row)">详细</Button>
								<br>
								<Button type="error" @click="newBackview(row)">新增回访记录</Button>
							</Submenu>
						</Menu>
						</Col>
					</Row>
				</template>
			</Table> -->
      <!--分页-->
      <!-- <Page :class="'m-2 text-right'" :page-size="tableInfo.pageSize" @on-change="pageSearch"
				:total="tableInfo.total" /> -->
    </Layout>
  </Layout>
</template>

<script>
export default {
  data() {
    return {
      resource: {
        source: '',
        statu: '',
        ypzw: '',
        csgz: '',
        tdgsmc: '',
        bz: '',
        autor: null,
        stageId: null,
      },
      interview: {
        des: '',
        flg: '',
        dateTime: '',
        autor: null,
        ypzw: '',
        stageId: null,
      },
      tryListening: {
        dateTime: '',
        autor: '',
        des: '',
        statu: '',
        stageId: null,
      },
      resourceBackviewTableInfo: {
        //----------------  resourceBackviewTableInfo
        currentPage: 1,
        total: 0,
        pageSize: 10,
        columnInfo: [
          {
            title: '回访编号',
            key: 'id',
          },
          {
            title: '回访类型',
            key: 'type',
          },
          {
            title: '回访人',
            key: 'autor',
          },
          {
            title: '回访描述',
            key: 'des',
          },
          {
            title: '回访结果',
            key: 'result',
          },
          {
            title: '回访日期',
            key: 'dateTime',
          },
          {
            title: '回访方式',
            key: 'method',
          },
          {
            title: '回访阶段Id',
            key: 'stageId',
          },
          {
            title: '操作',
            slot: 'action',
            width: 150,
          },
        ],
        data: [],
      },
      interviewBackviewTableInfo: {
        //----------------resourceInterviewTableInfo
        currentPage: 1,
        total: 0,
        pageSize: 10,
        columnInfo: [
          {
            title: '回访编号',
            key: 'id',
          },
          {
            title: '回访类型',
            key: 'type',
          },
          {
            title: '回访人',
            key: 'autor',
          },
          {
            title: '回访描述',
            key: 'des',
          },
          {
            title: '回访结果',
            key: 'result',
          },
          {
            title: '回访日期',
            key: 'dateTime',
          },
          {
            title: '回访方式',
            key: 'method',
          },
          {
            title: '回访阶段Id',
            key: 'stageId',
          },
          {
            title: '操作',
            slot: 'action',
            width: 150,
          },
        ],
        data: [],
      },
      tryBackviewTableInfo: {
        //----------------resourceBackviewTableInfo
        currentPage: 1,
        total: 0,
        pageSize: 10,
        columnInfo: [
          {
            title: '回访编号',
            key: 'id',
          },
          {
            title: '回访类型',
            key: 'type',
          },
          {
            title: '回访人',
            key: 'autor',
          },
          {
            title: '回访描述',
            key: 'des',
          },
          {
            title: '回访结果',
            key: 'result',
          },
          {
            title: '回访日期',
            key: 'dateTime',
          },
          {
            title: '回访方式',
            key: 'method',
          },
          {
            title: '回访阶段Id',
            key: 'stageId',
          },
          {
            title: '操作',
            slot: 'action',
            width: 150,
          },
        ],
        data: [],
      },
    }
  },
  methods: {
    init: function() {
      //初始化表格将表里面的数据全部分页查出来
      this.$data.tableInfo.currentPage = 0
      let _this = this
      this.http
        .get({
          url: 'http://127.0.0.1:8888/iou/student/list', //ajax
        })
        .then((data) => {
          this.$data.tableInfo.data = data
        })
    },
    newBackview: function(row) {
      this.$router.push({
        name: 'backview_new', //跳转至XX新增页面
        params: {
          row,
        },
      })
    },
    show: function(row) {
      let _this = this
      this.$router.push({
        name: 'backview_detail', //跳转至XX详细页面
        params: {
          row,
        },
      })
    },
    search: function() {
      let _this = this
      let page = this.$data.tableInfo.currentPage
      let URL = 'http://127.0.0.1:8888/iou/backview/list'
      this.http
        .get({
          url: URL,
          params: {
            page: 1,
            size: 2,
            'backview.des': _this.des,
            'backview.result': _this.result,
            'backview.method': _this.method,
            'backview.autor': ' ' + _this.autor,
            'backview.cu': _this.cu,
            'resource.source': _this.source,
            'student.name': _this.name,
            'student.tel': _this.tel,
          },
        })
        .then((data) => {
          let POJOList = new Array()
          for (let item in data.DATA.list) {
            let backviewId = data.DATA.list[item].backview.id
            let studentId = data.DATA.list[item].student.id
            let studentName = data.DATA.list[item].student.name
            let autor = data.DATA.list[item].backview.autor
            let des = data.DATA.list[item].backview.des
            let backviewDateTime = data.DATA.list[item].backview.dateTime
            let method = data.DATA.list[item].backview.method
            let source = data.DATA.list[item].resource.source
            let position = data.DATA.list[item].resource.csgz
            let POJO = {
              backviewId,
              studentId,
              studentName,
              autor,
              des,
              backviewDateTime,
              method,
              source,
              position,
            }
            POJOList.push(POJO)
          }
          this.$data.tableInfo.currentPage = data.DATA.page
          this.$data.tableInfo.total = data.DATA.total
          this.$data.tableInfo.pageSize = data.DATA.size
          this.$data.tableInfo.data = POJOList
        })
    },
    pageSearch: function(changedPage) {
      this.$data.tableInfo.currentPage = changedPage
      let _this = this
      let page = this.$data.tableInfo.currentPage
      let URL = 'http://127.0.0.1:8888/iou/backview/list'
      this.http
        .get({
          url: URL, //ajax
          params: {
            page: page,
            size: 2,
            'backview.des': _this.des,
            'backview.result': _this.result,
            'backview.method': _this.method,
            'backview.autor': ' ' + _this.autor,
            'backview.cu': _this.cu,
            'resource.source': _this.source,
            'student.name': _this.name,
            'student.tel': _this.tel,
          },
        })
        .then((data) => {
          let POJOList = new Array()
          for (let item in data.DATA.list) {
            let studentId = data.DATA.list[item].student.id
            let studentName = data.DATA.list[item].student.name
            let autor = data.DATA.list[item].backview.autor
            let des = data.DATA.list[item].backview.des
            let backviewDateTime = data.DATA.list[item].backview.dateTime
            let method = data.DATA.list[item].backview.method
            let source = data.DATA.list[item].resource.source
            let position = data.DATA.list[item].resource.csgz
            let POJO = {
              studentId,
              studentName,
              autor,
              des,
              backviewDateTime,
              method,
              source,
              position,
            }
            POJOList.push(POJO)
          }
          this.$data.tableInfo.currentPage = data.DATA.page
          this.$data.tableInfo.total = data.DATA.total
          this.$data.tableInfo.pageSize = data.DATA.size
          this.$data.tableInfo.data = POJOList
        })
    },
    remove: function(pId) {
      this.message.confirm({
        title: '删除提示',
        content: '即将删除权限，确定吗？',
        onOk: () => {
          this.http
            .delete({
              url: '/backview/delete', //删除url 待定......
              param: {},
            })
            .then((data) => {
              this.search()
            })
        },
        onCancel: () => {
          this.message.info('操作已取消')
        },
      })
    },
    formatDate: function(date) {
      //格式化日期方法! ----> yyyy-MM-dd
      var d = new Date(date),
        month = '' + (d.getMonth() + 1),
        day = '' + d.getDate(),
        year = d.getFullYear()

      if (month.length < 2) month = '0' + month
      if (day.length < 2) day = '0' + day
      return [year, month, day].join('-')
    },
  },
  created: function() {
    this.http
      .get({
        url: '/lifeCycle/list/1', //this.$route.params.row.id //ajax   我先写死啊 待一会改
      })
      .then((data) => {
        let _this = this
        _this.resource.source = data.resourceAndBackviewPOJO.resource.source
        _this.resource.statu = data.resourceAndBackviewPOJO.resource.statu
        _this.resource.ypzw = data.resourceAndBackviewPOJO.resource.ypzw
        _this.resource.csgz = data.resourceAndBackviewPOJO.resource.csgz
        _this.resource.tdgsmc = data.resourceAndBackviewPOJO.resource.tdgsmc
        _this.resource.bz = data.resourceAndBackviewPOJO.resource.bz
        _this.resource.autor = data.resourceAndBackviewPOJO.resource.autor
        _this.resource.stageId = data.resourceAndBackviewPOJO.resource.stageId

        _this.interview.des = data.interviewAndBackviewPOJO.interview.des
        _this.interview.flg = data.interviewAndBackviewPOJO.interview.flg
        _this.interview.dateTime =
          data.interviewAndBackviewPOJO.interview.dateTime
        _this.interview.autor = data.interviewAndBackviewPOJO.interview.autor
        _this.interview.ypzw = data.interviewAndBackviewPOJO.interview.ypzw
        _this.interview.stageId =
          data.interviewAndBackviewPOJO.interview.stageId

        _this.tryListening.des = data.tryAndBackviewPOJO.try.des
        _this.tryListening.statu = data.tryAndBackviewPOJO.try.statu
        _this.tryListening.autor = data.tryAndBackviewPOJO.try.autor
        _this.tryListening.dateTime = data.tryAndBackviewPOJO.try.dateTime
        _this.tryListening.stageId = data.tryAndBackviewPOJO.try.stageId

        // this.$data.tableInfo.currentPage = data.DATA.page;
        // this.$data.tableInfo.total = data.DATA.total;
        // this.$data.tableInfo.pageSize = data.DATA.size;
        this.$data.resourceBackviewTableInfo.data =
          data.resourceAndBackviewPOJO.backviewList
        this.$data.interviewBackviewTableInfo.data =
          data.interviewAndBackviewPOJO.backviewList
        this.$data.tryBackviewTableInfo.data =
          data.tryAndBackviewPOJO.backviewList
      })
  },
}
</script>

<style></style>
